<%@page import="com.erp.po.Admin"%>
<%@page import="com.erp.service.AdminServiceImpl"%>
<%@page import="java.io.PrintWriter"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>

<%
//解决中文了乱码
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setContentType("text/html;UTF-8");
		
		String name = request.getParameter("userName");
		String pwd = request.getParameter("password");
		
		AdminServiceImpl as = new AdminServiceImpl();
		Admin admin = as.findAdminByLogin(new Admin(name, pwd));
		
		if (admin != null) {
			session.setAttribute("loginName", admin.getAdminName());
			response.sendRedirect("main.jsp");
		} else {
			out.write("<script>alert('- 对不起,你的用户名或者密码错误!请重新输入. -');location.href = 'index.jsp';</script>");
		}


%>

</body>
</html>